﻿#include "gtsort.h"

#include <stdio.h>

int compare(const void *left, const void *right, void *context)
{
	int prev = *(const int*)left;
	int next = *(const int*)right;
	if (prev < next)
		return -1;
	else if (prev > next)
		return 1;
	else
		return 0;
}

#define N 10

int main()
{
	int array[N];
	printf("输入%d个整数：", N);
	for (int i = 0; i < N; ++i)
		scanf("%d", &array[i]);

	sort(array, N, sizeof(int), compare, NULL);

	printf("排序之后：");
	for (int i = 0; i < N; ++i)
		printf("%d ", array[i]);
	puts("\b");
	return 0;
}
